
package com.craterhill.java.ems.dao.impl;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.craterhill.java.ems.common.beans.Classes;
import com.craterhill.java.ems.dao.ClassesDao;

@Repository
public class ClassesDaoImpl extends AbstractDao<Classes> implements ClassesDao {

	@Autowired
	public ClassesDaoImpl(final DataSource dataSource) {
		super(dataSource);
	}

	@Override
	public List<Classes> findAll() {
		return super.findMultipleObject(FIND_ALL_CLASSES, new ClassesExtractor());
	}

	@Override
	public Classes find(int recordId) {
		return super.findSingleObject(FIND_CLASSES, new ClassesExtractor(), recordId);
	}

	@Override
	public boolean remove(final Integer... classIds) {
		return super.batchOperation(DELETE_CLASSES, new DaoBatchPreparedStatementSetter(classIds));
	}

	@Override
	public int save(final Classes classes) {
		return super.save(new ClassesPreparedStatementCreator(ACTION_SAVE, classes));
	}

	@Override
	public boolean update(final Classes classes) {
		return super.update(new ClassesPreparedStatementCreator(ACTION_UPDATE, classes));
	}
}
